package arkham.data;

import java.util.List;
import java.util.ArrayList;

/**
 * This is the base class for any locations, other worlds, or
 * special locations. It specifies a set of containers for holding
 * investigators and monsters.
 * @author ctheng
 *
 */
public class LocationContainer implements NamedEntity
{

	protected String name;
	protected List<Investigator> investigatorList;
	protected List<Monster> monsterList;

	public LocationContainer(String name)
	{
		this.name = name;
		investigatorList = new ArrayList<Investigator>();
		monsterList = new ArrayList<Monster>();
	}

	/*
	 * (non-Javadoc)
	 * @see arkham.data.NamedEntity#getName()
	 */
	public String getName()
	{
		return name;
	}

	/**
	 * Gets the number of investigators
	 * @return the number of investigators
	 */
	public int getNumInvestigators()
	{
		return investigatorList.size();
	}

	/**
	 * Gets the number of monsters
	 * @return the number of monsters
	 */
	public int getNumMonsters()
	{
		return monsterList.size();
	}

	/**
	 * Gets the list of investigators here
	 * @return the investigator list
	 */
	public List<Investigator> getInvestigatorList() {
		return investigatorList;
	}

	/**
	 * Gets the list of monsters here
	 * @return the monster list
	 */
	public List<Monster> getMonsterList() {
		return monsterList;
	}

	/**
	 * Cycles the top investigator to the bottom
	 */
	public void cycleInvestigators()
	{
		if (investigatorList.size() > 1)
		{
			Investigator temp = investigatorList.remove(0);
			investigatorList.add(temp);
		}
	}

	/**
	 * Cycles the top monster to the bottom
	 */
	public void cycleMonsters()
	{
		if (monsterList.size() > 1)
		{
			Monster temp = monsterList.remove(0);
			monsterList.add(temp);
		}
	}

	/**
	 * Checks if this location is in Arkham.
	 * Child classes should override this method.
	 * @return true if this location is in Arkham
	 */
	public boolean isArkhamLocation()
	{
		return false;
	}

	@Override
	public boolean equals(Object o)
	{
	    if (o instanceof LocationContainer)
	    {
	        return ((LocationContainer)o).getName().equals(this.getName());
	    }
	    return false;
	}
}
